# coding: utf-8
import random
import datetime
import sys

reload(sys)
sys.setdefaultencoding('utf8')

lastname = u"白日登山望烽火黄昏饮马傍交河行人刁斗风沙暗公主琵琶幽怨多野云万里无城郭雨雪纷纷连大漠胡雁哀鸣"
firstname = u"夜夜飞胡儿眼泪双双落闻道玉门犹被遮应将性命逐轻车年年战骨埋荒外空见蒲桃入汉家"

def create_student_dict(start):
    firstlen = len(firstname)
    lastlen = len(lastname)

    scoreList = [int(random.normalvariate(100, 50)) for _ in xrange(1, 5000)]
    filename = str(start) + '.txt'
    print filename

    with open('./' + filename, mode='wr+') as fp:
        for i in xrange(start * 40000, (start + 1) * 40000):
            firstind = random.randint(1, firstlen - 4)
            model = {"s_no": u"xuehao_no_" + str(i),
                     "s_name": u"{0}{1}".format(lastname[random.randint(1, lastlen - 1)],
                                                firstname[random.randint(1, firstlen - 1)]),
                     "s_birth": u"{0}-{1}-{2}".format(random.randint(1991, 2000),
                                                      '0' + str(random.randint(1, 9)),
                                                      random.randint(10, 28)),
                     "s_age": random.sample([20, 20, 20, 20, 21, 22, 23, 24, 25, 26], 1)[0],
                     "s_sex": str(random.sample(['男', '女'], 1)[0]),
                     "s_score": abs(scoreList[random.randint(1000, 4990)]),
                     "s_desc": u"Hello World!"
                     }
            fp.write("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\n".format(
                model['s_no'], model['s_name'],
                model['s_birth'], model['s_age'],
                model['s_sex'], model['s_score'],
                model['s_desc']
            ))

for i in xrange(1, 501):
    starttime = datetime.datetime.now()
    create_student_dict(i)
